package cache_service

import (
	"strconv"
	"strings"
)

type Salesmen struct {
	ID int

	PageNum  int
	PageSize int
	Keyword  string
}

const CacheSalemen = "Cache_Salemen"

func (s *Salesmen) GetSalemenKey() string {
	return CacheSalemen + "_" + strconv.Itoa(s.ID)
}

func (s *Salesmen) GetSalesmenKey() string {
	keys := []string{
		CacheSalemen,
		"LIST",
	}

	if s.ID > 0 {
		keys = append(keys, strconv.Itoa(s.ID))
	}
	if s.PageNum > 0 {
		keys = append(keys, strconv.Itoa(s.PageNum))
	}
	if s.PageSize > 0 {
		keys = append(keys, strconv.Itoa(s.PageSize))
	}
	if len(s.Keyword) > 0 {
		keys = append(keys, s.Keyword)
	}

	return strings.Join(keys, "_")
}
